﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinScriptEngine.Parses.Interface;
using WinScriptEngine.Parses.Scope;

namespace WinScriptEngine.Parses.Impl
{
    /// <summary>
    /// 空白字符解析类
    /// </summary>
    class WhiteParseImpl : SingletonObject<WhiteParseImpl>, IParse
    {
        public string VTypeName => "White";

        public bool Invoke(InvokeEnvironment vCpu)
        {
            throw new NotImplementedException();
        }

        public Metadata Parse(ref Metadata upper, IEnumerator<char> position)
        {
            while (position.MoveNext())
            {
                if (!this.TryParse(ref upper, position.Current))
                    break;
            }
            return null;
        }

        public bool TryParse(ref Metadata upper, char curChar)
        {
            return curChar == '\r'
                || curChar == '\n'
                || curChar == ' '
                || curChar == '\t';
        }
    }
}
